Conversation
…W_PHASE, GH_AW_VERSION runtime variables Added a new "System-Injected Runtime Variables" section documenting the three env vars automatically injected by the gh-aw compiler into every agentic engine execution step (PR #20382). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds missing documentation for system-injected runtime environment variables exposed to agentic engine execution steps, addressing a late-merge documentation gap.
Changes:
- Added a new System-Injected Runtime Variables section documenting
GITHUB_AW,GH_AW_PHASE, andGH_AW_VERSION - Included a table of meanings plus a compiled-workflow
env:example and a NOTE about override behavior
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
|
||
| ## System-Injected Runtime Variables | ||
|
|
||
| GitHub Agentic Workflows automatically injects the following environment variables into every agentic engine execution step (both the main agent run and the threat detection run). These variables are read-only from the agent's perspective and are useful for writing workflows or agents that need to detect their execution context. |
There was a problem hiding this comment.
The sentence uses incorrect verb agreement: “GitHub Agentic Workflows … injects” should be “inject” (plural subject).
| GitHub Agentic Workflows automatically injects the following environment variables into every agentic engine execution step (both the main agent run and the threat detection run). These variables are read-only from the agent's perspective and are useful for writing workflows or agents that need to detect their execution context. | |
| GitHub Agentic Workflows automatically inject the following environment variables into every agentic engine execution step (both the main agent run and the threat detection run). These variables are read-only from the agent's perspective and are useful for writing workflows or agents that need to detect their execution context. |
| | `GITHUB_AW` | `"true"` | Present in every gh-aw engine execution step. Agents can check for this variable to confirm they are running inside a GitHub Agentic Workflow. | | ||
| | `GH_AW_PHASE` | `"agent"` or `"detection"` | Identifies which execution phase is active. `"agent"` for the main run; `"detection"` for the threat-detection safety check run that precedes the main run. | | ||
| | `GH_AW_VERSION` | e.g. `"0.40.1"` | The gh-aw compiler version that generated the workflow. Useful for conditional logic that depends on a minimum feature version. | | ||
|
|
||
| These variables appear alongside other `GH_AW_*` context variables in the compiled workflow: | ||
|
|
||
| ```yaml | ||
| env: | ||
| GITHUB_AW: "true" | ||
| GH_AW_PHASE: agent # or "detection" | ||
| GH_AW_VERSION: "0.40.1" |
There was a problem hiding this comment.
The documented example values don’t match the compiled workflows produced by the compiler: lock files show GITHUB_AW: true (unquoted) and GH_AW_VERSION is typically a short build/version string (e.g. 3f30e4d), not necessarily a semver like 0.40.1. Consider updating the table and YAML example to reflect the actual emitted values (or clarify that it may be a commit SHA / dev / release version depending on build).
| | `GITHUB_AW` | `"true"` | Present in every gh-aw engine execution step. Agents can check for this variable to confirm they are running inside a GitHub Agentic Workflow. | | |
| | `GH_AW_PHASE` | `"agent"` or `"detection"` | Identifies which execution phase is active. `"agent"` for the main run; `"detection"` for the threat-detection safety check run that precedes the main run. | | |
| | `GH_AW_VERSION` | e.g. `"0.40.1"` | The gh-aw compiler version that generated the workflow. Useful for conditional logic that depends on a minimum feature version. | | |
| These variables appear alongside other `GH_AW_*` context variables in the compiled workflow: | |
| ```yaml | |
| env: | |
| GITHUB_AW: "true" | |
| GH_AW_PHASE: agent # or "detection" | |
| GH_AW_VERSION: "0.40.1" | |
| | `GITHUB_AW` | `true` | Present in every gh-aw engine execution step. Agents can check for this variable to confirm they are running inside a GitHub Agentic Workflow. | | |
| | `GH_AW_PHASE` | `"agent"` or `"detection"` | Identifies which execution phase is active. `"agent"` for the main run; `"detection"` for the threat-detection safety check run that precedes the main run. | | |
| | `GH_AW_VERSION` | e.g. `"3f30e4d"` | The gh-aw compiler version that generated the workflow (often a short commit SHA, `dev`, or a release version). Useful for conditional logic that depends on a minimum feature version. | | |
| These variables appear alongside other `GH_AW_*` context variables in the compiled workflow: | |
| ```yaml | |
| env: | |
| GITHUB_AW: true | |
| GH_AW_PHASE: agent # or "detection" | |
| GH_AW_VERSION: "3f30e4d" # e.g. short commit SHA, dev, or release version |
| ``` | ||
|
|
||
| > [!NOTE] | ||
| > These variables are injected by the compiler and cannot be overridden by user-defined `env:` blocks in the workflow frontmatter. |
There was a problem hiding this comment.
The NOTE claims these variables “cannot be overridden by user-defined env: blocks in the workflow frontmatter”, but the compiler currently injects these keys and then merges user-provided engine.env / agent env afterwards (e.g. maps.Copy(env, workflowData.EngineConfig.Env) in pkg/workflow/copilot_engine_execution.go), which allows overriding GITHUB_AW, GH_AW_PHASE, or GH_AW_VERSION. Either adjust the docs to reflect actual precedence, or reserve/validate these names in the compiler so the NOTE stays accurate.
| > These variables are injected by the compiler and cannot be overridden by user-defined `env:` blocks in the workflow frontmatter. | |
| > These variables are injected by the compiler as defaults for the engine execution context. They can be overridden by user-defined `engine.env` or agent-specific `env` blocks in the workflow frontmatter, but are not affected by workflow-, job-, or step-level `env:` scopes. |
Self-Healing Documentation Fixes
This PR was automatically created by the Daily Documentation Healer workflow.
Gaps Fixed
environment-variables.mddocumentingGITHUB_AW,GH_AW_PHASE, andGH_AW_VERSION. These three variables are automatically injected into every agentic engine execution step (bothagentanddetectionphases) but were not present anywhere in the docs.Root Cause
DDUw ran at 04:22 UTC on 2026-03-10 and produced PR #20306 (merged 04:47 UTC). PR #20382 (
Add GITHUB_AW, GH_AW_PHASE, and GH_AW_VERSION env vars) was merged at 16:40 UTC — over 12 hours after DDUw completed. This is the same late-merge blind-spot pattern as the previous healer run (PR #20254), where a late-day merge falls entirely outside DDUw's scan window.DDUw Improvement Suggestions
Analyzed Issues (last 7 days, label: documentation, state: closed)
staged-mode.mdpage)docs/research/file, notdocs/docs/The gap for
GITHUB_AW/GH_AW_PHASE/GH_AW_VERSIONwas discovered by cross-referencing commits merged after DDUw's last run, not from a closed issue.Files Changed
docs/src/content/docs/reference/environment-variables.md— added "System-Injected Runtime Variables" section with table and code example forGITHUB_AW,GH_AW_PHASE,GH_AW_VERSIONRelated
GITHUB_AW,GH_AW_PHASE, andGH_AW_VERSIONenv vars to agentic engine execution steps (merged 2026-03-10T16:40Z, after DDUw's 04:22Z run)